package com.itheima.service.rabbitMQ;

import com.itheima.service.MessageService;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MessageServiceRabbitMQImpl implements MessageService {

    //创建amqp的操作对象
    @Autowired
    private AmqpTemplate amqpTemplate;

    @Override
    public void sendMessage(String id) {
        System.out.println("待发送短信的订单已纳入处理队列（rabbitmq direct），id："+id);
        //将消息放入队列,指定交换机和绑定关系,虽然有默认值，但是我们一般会指定
        amqpTemplate.convertAndSend("directExchange","direct",id);
    }

    @Override
    public String doMessage(String id) {
        return null;
    }
}
